<?php

namespace App\Listener;

use App\Events\AdminLogEvent;
use App\Models\AdminLog;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;

class AdminLogListener implements ShouldQueue
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  \App\Events\AdminLogEvent  $event
     * @return void
     */
    public function handle(AdminLogEvent $event)
    {
        try {
            AdminLog::insert($event->data);
        } catch (\Throwable $e) {
            \Log::error($e->getMessage(), $e->getTrace());
        }
    }
}
